#include <iostream>
#include <vector>
/*
冒泡排序算法
*/
template <typename T> void bubble_sort(std::vector<T> &list) {
  int i = 0, j = list.size();
  for (; i < j; i++) {
    bool flag = false;
    for (int k = j; k > i; k--) {
      if (list[k] < list[k - 1]) {
        T t = list[k - 1];
        list[k - 1] = list[k];
        list[k] = t;
        flag = true;
      }
    }
    if (!flag) {
      return;
    }
  }
}

int main() {
  std::vector<int> list = {2, 4, 3, 6, 7, 3, 4, 2};
  bubble_sort<int>(list);
  for (int &i : list) {
    std::cout << i;
  }
  return 0;
}